//
//  HelpMeBagApplyFinishVC.m
//  MRBang
//
//  Created by 铅笔 on 16/5/9.
//  Copyright © 2016年 杭州易网新科技. All rights reserved.
//

#import "HelpMeBagApplyFinishVC.h"

@interface HelpMeBagApplyFinishVC ()
@property (nonatomic,strong) UIView *view_topFirstStepBG;
@end

@implementation HelpMeBagApplyFinishVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = COLOR_EVERYVIEWBG;
    self.title = @"帮我贷";
    
    [self initWithHelpMeBagApplyFinishVCSubviews];
    
    //button
    UIButton *button_nextStep = [[UIButton alloc] initWithFrame:CGRectMake(48*PROPORTION_WIDTH,170*PROPORTION_WIDTH+self.view_topFirstStepBG.bottom,kScreenWidth - 48*PROPORTION_WIDTH*2, 93*PROPORTION_WIDTH)];
    
    [self.view addSubview:button_nextStep];
    
    button_nextStep.backgroundColor = COLOR_BUTTON;
    
    [button_nextStep setTitle:@"完成申请" forState:UIControlStateNormal];
    [button_nextStep setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [button_nextStep.titleLabel setFont:[UIFont systemFontOfSize:Font_SIZE_18*2]];
    button_nextStep.layer.cornerRadius = 3.0;
    button_nextStep.clipsToBounds = YES;
    
    [button_nextStep addTarget:self action:@selector(DataSourceRequestHelpMeBagBankListView) forControlEvents:UIControlEventTouchUpInside];
}

#pragma mark --- 创建视图界面
- (void) initWithHelpMeBagApplyFinishVCSubviews
{
    self.view_topFirstStepBG = [[UIView alloc] initWithFrame:CGRectMake(0, 64, kScreenWidth, 223*PROPORTION_WIDTH)];
    [self.view addSubview:self.view_topFirstStepBG];
    self.view_topFirstStepBG.backgroundColor = [UIColor whiteColor];
    
    //展位的背景图
    UIImageView *imageView_fullImage = [[UIImageView alloc] initWithFrame:CGRectMake(73*PROPORTION_WIDTH,48*PROPORTION_WIDTH, kScreenWidth-73*PROPORTION_WIDTH*2, 133*PROPORTION_WIDTH)];
    [self.view_topFirstStepBG addSubview:imageView_fullImage];
    imageView_fullImage.image = [UIImage imageNamed:@"step3"];
    
    //UILable
    UILabel *label_tipsText = [[UILabel alloc] initWithFrame:CGRectMake(215*PROPORTION_WIDTH, self.view_topFirstStepBG.bottom+53*PROPORTION_WIDTH, kScreenWidth-215*PROPORTION_WIDTH*2, 100*PROPORTION_WIDTH)];
    [self.view addSubview:label_tipsText];
    
    label_tipsText.text = @"请保持手机畅通，我们会尽快受理您的申请，祝您早日实现梦想！";
    label_tipsText.font = [UIFont systemFontOfSize:Font_SIZE_18];
    label_tipsText.numberOfLines = 2;
    [label_tipsText sizeToFit];
    label_tipsText.textAlignment = NSTextAlignmentCenter;
    label_tipsText.textColor = COLOT_TEXTGRAY;
}

//#pragma mark --- 完成申请
//- (void) ApplayNowFinishApplyAction
//{
//    NSLog(@"finish");
//}

#pragma mark -- 网络数据请求
- (void) DataSourceRequestHelpMeBagBankListView
{
    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    
    Reachability *reach = [Reachability reachabilityForInternetConnection];
    NetworkStatus status = [reach currentReachabilityStatus];
    
    if (![UIView NetFromStatus:status]) {
        NSLog(@"没有网络");
        [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
        [UIView showAlertMsg:@"网络连接已断开" andShowBgColor:[UIColor blackColor] andLabelTectColor:[UIColor whiteColor]];
        return;
    }
    else
    {
        NSString *strUrl = [NSString stringWithFormat:@"%@loan/add",MRAPI];
        NSDictionary *paras_addBag = @{
                                        @"memberid":[[NSUserDefaults standardUserDefaults] objectForKey:@"memberid"],
                                        @"mobile":self.mutableDic_pathBagInfo[@"mobile"],
                                        @"name":self.mutableDic_pathBagInfo[@"name"],
                                        @"idcard":self.mutableDic_pathBagInfo[@"idcard"],
                                        @"zhiyeshenf":self.mutableDic_pathBagInfo[@"zhiyeshenf"],
                                        @"isyougjj":self.mutableDic_pathBagInfo[@"isyougjj"],
                                        @"isshebao":self.mutableDic_pathBagInfo[@"isshebao"],
                                        @"hometype":self.mutableDic_pathBagInfo[@"hometype"],
                                        @"iscar":self.mutableDic_pathBagInfo[@"iscar"],
                                        @"cardqingk":self.mutableDic_pathBagInfo[@"cardqingk"],
                                        @"age":self.mutableDic_pathBagInfo[@"age"],
                                        @"loanamount":self.mutableDic_pathBagInfo[@"loanamount"],
                                        @"period":self.mutableDic_pathBagInfo[@"period"],
                                        @"poundage":self.mutableDic_pathBagInfo[@"poundage"],
                                        @"loanbanks":self.mutableDic_pathBagInfo[@"loanbanks"],};
        
        NSLog(@"%@  ----- %@",strUrl,paras_addBag);
        
        [[HttpRequest shardWebUtil] postNetworkRequestURLString:strUrl parameters:paras_addBag success:^(id obj) {
            NSLog(@"bagbag%@--%@",obj,obj[@"error"]);
            
            [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
            NSString *str_false = obj[@"error"];
            
            if (str_false.length==0) {
                
                [UIView showAlertMsg:@"申请成功"];
                [self.navigationController popToRootViewControllerAnimated:YES];
            }
        } fail:^(NSError *error) {
            NSLog(@"bagbag%@",error);
            [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
            [UIView showAlertMsg:@"网络请求超时"];
            
        }];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

@end
